-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add transitive guidance #3336
Add transitive guidance #3336
Conversation
Learn Build status updates of commit ceec92d: 💡 Validation status: suggestions
docs/concepts/Auditing-Packages.md
For more details, please refer to the build report. Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them. For any questions, please:
|
docs/concepts/Auditing-Packages.md
Outdated
|
||
If a known vulnerability exists in a top-level package's transitive dependencies, you have these options: | ||
|
||
- Add the fixed package version as a direct package reference. **Note:** Be sure to remove this reference when a new package version update becomes available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also tell folks to take care when doing this that they don't change the deployment behavior of their project. I've seen folks hoist a dependency that was marked with PrivateAssets and ExcludeAssets and forget to add those same markings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like?
Note: This does not change the deployment behavior in any way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean the user needs to take care to make sure that they don't do this. So if they were previously doing:
<PackageRefence Include="Direct" Version="1.0.0" PrivateAssets="All" ExcludeAssets="Runtime" />
They should take care when adding a new reference to give it the same:
<PackageRefence Include="Direct" Version="1.0.0" PrivateAssets="All" ExcludeAssets="Runtime" />
<!-- Note: Apply the same values for PrivateAssets and ExcludeAssets as Direct -->
<PackageRefence Include="Indirect" Version="1.1.0" PrivateAssets="All" ExcludeAssets="Runtime"/>
It's not automatic here. It is for CPM - that's a major benefit it gives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we say: Take care when adding the dependency to match the Assets settings of the existing dependency. When doing so it should behave in the same way as if your dependency itself was updated. This is not required when using CPM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. "whne adding a explicit reference, ensure you maintain your packagereference attributes for the asset behavior" etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused, or I think we have inconsistent behaviour (which now would be a breaking change to fix). Today, so coincidence it's on the same day, I was pinged on Discord because someone claims that a package reference with ExcludeAssets="runtime"
does not exclude that package's dependencies runtime assets, and they had to manually list every transitive package as direct references and add the same ExcludeAssets="runtime"
.
If CPM's central pinning does flow through include/private/exclude assets, then it sounds like it changes behaviour compared to the same package not being pinned, which feel like a bug to me.
I just did a super quick test, and it looks like excludeassets does flow, so the person on discord who pinged me has a more complex scenario.
I think yes, it is worth mentioning. Include/Private/Exclude Assets might not be used by a high percentage of customers, but I would be surprised if the people using it will remember that asset group selection flows when they promote a transitive package to a direct reference (especially since none of our tools (VS, or dotnet add package
) provide a way to view or edit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a good example of the sort of thing that makes this complicated: dotnet/aspnetcore#57560 (comment)
If a known vulnerability exists in a top-level package's transitive dependencies, you have these options: | ||
|
||
- Add the fixed package version as a direct package reference. **Note:** Be sure to remove this reference when a new package version update becomes available. | ||
- Use [Central Package Management with the transitive pinning functionality](https://learn.microsoft.com/nuget/consume-packages/Central-Package-Management#transitive-pinning). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should explicitly warn people that if they pack the project into a package, the pinned package will become a package dependency. The linked doc mentions that it promotes a package to a top level dependency, but the very first two customers who tested the first CPM prototype didn't understand this, complained, and stopped using CPM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That probably belongs in the CPM docs. Remind folks that rolling up dependencies doesn't actually add any new dependencies than what you already have. Maybe NuGet gallery could even help here by showing authored dependencies visually different than transitive ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nuget.org (NuGetGallery) only show dependencies listed in the nuspec, so only direct dependencies, not transitive dependencies.
Any package that CPM promotes via transitive pinning becomes a direct dependency (the page on CPM explicitly states this), and therefore it will be listed in the nuspec as a dependency. NuGet Gallery has no way to know that "this was a transitive package that was pinned by the project that it was packed from". The very first 2 customers who tried CPM (both package authors) when it was in preview and transitive pinning was default with no option to disable, immediately said they hated it and stopped using CPM. So, I think it's valuable to set expectations.
I still see transitive pinning (or direct references) as a valid way for library authors to remove transitive packages with known vulnerabilities. But if a single repo is building both packages and apps, the developer might not want to cause a transitive package like System.Text.Json to become a direct dependency of their package, when they upgrade the package for the web/gui/console apps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's another challenge here that the CPM docs aren't really complete in this scenario.
Separate problem: NuGet/Home#13811.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what I was thinking with my last reply. Let me try again to make it more clear:
Even if it's documented elsewhere, the first set of customers who tried transitive pinning hated it because it caused additional package dependencies, and told us they immediately stopped using it. I'm sure those two people were not unique and other customers will feel similarly. Therefore, if we're going to advise people to use the feature, I think we should set expectations so they're not surprised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah fair, I was just pointing out that we have another gap to close, which is document it for CPM in the first place.
Added clarifications. Would like to get this initial set included ASAP to live docs. Anything else? Otherwise please feel free to approve and/or commit directly here so I can get this in live docs. |
Learn Build status updates of commit 061cc2c: 💡 Validation status: suggestions
docs/concepts/Auditing-Packages.md
For more details, please refer to the build report. Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them. For any questions, please:
|
bump. still waiting an approval to get these initial items included officially in the docs. |
- Add the fixed package version as a direct package reference. **Note:** Be sure to remove this reference when a new package version update becomes available and be sure to maintain the defined attributes for the expected behavior. | ||
- Use [Central Package Management with the transitive pinning functionality](https://learn.microsoft.com/nuget/consume-packages/Central-Package-Management#transitive-pinning). | ||
- [Suppress the advisory](https://learn.microsoft.com/nuget/concepts/auditing-packages#excluding-advisories) until it can be addressed. | ||
- File an issue in the top-level package's tracker to request an update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could add a link to the dotnet nuget why command
or Visual Studio transitive dependencies
feature documentation to identify the top-level package. I am okay with addressing this comment in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jebriede solution explorer ships what release again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JonDouglas do you mean transitive dependencies in Solution-level PM UI? If so, 17.12.
I'm moving forward to merge this. Let's please address whatever other items in follow-up as my intentions here are to include basic transitive guidance and not every specific. For example, please go update the CPM docs on specific "gotchas" and any last resort auditing advice in future PRs. |
/cc @ericstj